import uuid

import pytest

from recruit.domain.models.resume_skill import (
    BaseResumeSkill,
    ResumeSkillCreate,
    ResumeSkillResult,
    ResumeSkillUpdate,
)
from .utils import check_attr_model, check_json_schema


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'skills': ['skill']
            },
            ('skills',)
    )]
)
def test_resume_skill_base(
        data: dict[str, list[str]],
        keys: tuple[str, ...]
) -> None:
    check_attr_model(BaseResumeSkill, data)
    check_json_schema(BaseResumeSkill, keys)


@pytest.mark.parametrize(
    'data', [{
        'skills': []
    }]
)
def test_validate_in_resume_skill_base(data: dict[str, list]) -> None:
    with pytest.raises(ValueError):
        BaseResumeSkill(**data)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'skills': ['skill']
            },
            ('skills',)
    )]
)
def test_resume_skill_create(
        data: dict[str, list[str]],
        keys: tuple[str, ...]
) -> None:
    check_attr_model(ResumeSkillCreate, data)
    check_json_schema(ResumeSkillCreate, keys)


@pytest.mark.parametrize(
    'data', [{
        'skills': []
    }]
)
def test_validate_in_resume_skill_create(data: dict[str, list]) -> None:
    with pytest.raises(ValueError):
        ResumeSkillCreate(**data)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'id': uuid.uuid4(),
                'skills': ['skill']
            },
            ('id', 'skills')
    )]
)
def test_resume_skill_result(
        data: dict[str, list[str]],
        keys: tuple[str, ...]
) -> None:
    check_attr_model(ResumeSkillResult, data)
    check_json_schema(ResumeSkillResult, keys)


@pytest.mark.parametrize(
    'data, keys', [(
            {
                'skills': ['skill']
            },
            ('skills',)
    )]
)
def test_resume_skill_update(
        data: dict[str, list[str]],
        keys: tuple[str, ...]
) -> None:
    check_attr_model(ResumeSkillUpdate, data)
    check_json_schema(ResumeSkillUpdate, keys)
    check_attr_model(ResumeSkillUpdate, {}, tuple(data))
    check_json_schema(ResumeSkillUpdate, keys)
